#pragma once

namespace mmath
{
	class BoundingSphere;

	struct FrustumPersp
	{
		XMFLOAT4 Planes[6];
		XMFLOAT3 Points[8];

		XMFLOAT3 Position;
		XMFLOAT3 Forward;
		XMFLOAT3 Up;
		XMFLOAT3 Right;

		float FieldOfView;
		float AspectRatio;
		float NearZ;
		float FarZ;

		void construct(const XMVECTOR & position, const XMVECTOR & forward, const XMVECTOR & up, const XMVECTOR & right, float fov, float aspectRatio, float nearZ, float farZ);
		
	};

	struct FrustumOrtho
	{
		XMFLOAT4 Planes[6];
		XMFLOAT3 Points[8];

		XMFLOAT3 Position;
		XMFLOAT3 Forward;
		XMFLOAT3 Up;
		XMFLOAT3 Right;

		float Width;
		float Height;
		float NearZ;
		float FarZ;

		void construct(const XMVECTOR & position, const XMVECTOR & forward, const XMVECTOR & up, const XMVECTOR & right, float width, float height, float nearZ, float farZ);
		//bool intersects(const BoundingSphere & sphere) const;
		//void getBoundingSphere(BoundingSphere & sphere) const;
	};

	bool frustumSphereintersects(const XMFLOAT4 * planes, const BoundingSphere & sphere);
	BoundingSphere getFrustumBoundingSphere(const XMFLOAT3 * points);
}